import StoreAPI from "@/api/store";
import type { ISearchConfig } from "@/components/CURD/types";

const searchConfig: ISearchConfig = {
  pageName: "sys:user",
  formItems: [
    {
      type: "date-picker",
      label: "创建时间",
      prop: "createAt",
      attrs: {
        type: "daterange",
        "range-separator": "~",
        "start-placeholder": "开始时间",
        "end-placeholder": "截止时间",
        "value-format": "YYYY-MM-DD",
        style: {
          width: "240px",
        },
      },
    },
    {
      type: "select",
      label: "直属代理",
      prop: "status",
      attrs: {
        placeholder: "全部",
        clearable: true,
        style: {
          width: "240px",
        },
      },
      options: [
        { label: "待审核", value: 1 },
        { label: "正常", value: 0 },
        { label: "驳回", value: 0 },
      ],
    },
    {
      type: "select",
      label: "商务账号",
      prop: "status",
      attrs: {
        placeholder: "全部",
        clearable: true,
        style: {
          width: "240px",
        },
      },
      options: [
        { label: "待审核", value: 1 },
        { label: "正常", value: 0 },
        { label: "驳回", value: 0 },
      ],
    },
    {
      type: "select",
      label: "审核状态",
      prop: "reviewStatus",
      attrs: {
        placeholder: "全部",
        clearable: true,
        style: {
          width: "240px",
        },
      },
      options: [
        { label: "待审核", value: 0 },
        { label: "审核通过", value: 1 },
        { label: "审核未通过", value: 2 },
      ],
    },
    {
      type: "input",
      label: "商家编号",
      prop: "storeCode",
      attrs: {
        placeholder: "商家编号",
        clearable: true,
        style: {
          width: "240px",
        },
      },
    },
    {
      type: "input",
      label: "商家名称",
      prop: "name",
      attrs: {
        placeholder: "商家名称",
        clearable: true,
        style: {
          width: "240px",
        },
      },
    },
    {
      type: "select",
      label: "商家分类",
      prop: "cid",
      attrs: {
        placeholder: "全部",
        clearable: true,
        data: [],
        style: {
          width: "240px",
        },
      },
      async initFn(formItem) {
        formItem.attrs.data = await StoreAPI.getCategoryOptions();
      },
    },
    // {
    //   type: "tree-select",
    //   label: "部门",
    //   prop: "deptId",
    //   attrs: {
    //     placeholder: "请选择",
    //     data: [],
    //     filterable: true,
    //     "check-strictly": true,
    //     "render-after-expand": false,
    //     clearable: true,
    //     style: {
    //       width: "150px",
    //     },
    //   },
    //   async initFn(formItem) {
    //     formItem.attrs.data = await DeptAPI.getOptions();
    //     // 注意:如果initFn函数不是箭头函数,this会指向此配置项对象,那么也就可以用this来替代形参formItem
    //     // this.attrs!.data = await DeptAPI.getOptions();
    //   },
    // },
  ],
  isExpandable: false,
};

export default searchConfig;
